package com.miplus.ccrm.core.controller;

import com.miplus.ccrm.common.CmdResVo;
import com.miplus.ccrm.common.JSysUser;
import com.miplus.ccrm.common.R;
import com.miplus.ccrm.core.controller.vo.ficase.ImpResultVo;
import com.miplus.ccrm.core.controller.vo.sto.CockCaseVo;
import com.miplus.ccrm.core.controller.vo.sto.CockDelVo;
import com.miplus.ccrm.core.controller.vo.sto.CockImpVo;
import com.miplus.ccrm.core.controller.vo.sto.CrtFiCaseVo;
import com.miplus.ccrm.core.security.JCommonData;
import com.miplus.ccrm.core.service.sto.CreditCockcollectService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 2-7.项目个性化服务接口
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/sto")
public class StoController {
    @Resource
    private JCommonData jCommonData;
    @Resource
    private CreditCockcollectService cockcollectService;

    /**
     * 导入公鸡贷
     */
    @PostMapping("/impCockList")
    public R<ImpResultVo> impCockList(@RequestBody @Validated CockImpVo cockImpVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(cockcollectService.impCockList(usrid,cockImpVo));
    }

    /**
     * 生成公鸡贷案件
     */
    @PostMapping("/createCockCase")
    public R<CmdResVo> createCockCase(@RequestBody @Validated CrtFiCaseVo crtFiCaseVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(cockcollectService.CreateFiCase(usrid,crtFiCaseVo));
    }

    /**
     * 删除公鸡贷批次
     */
    @PostMapping("/deleteCockBatch")
    public R<CmdResVo> deleteCockBatch(@RequestBody @Validated CockDelVo cockDelVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(cockcollectService.DeleteFiCase(usrid,cockDelVo.getBatchid()));
    }

    /**
     * 取公鸡贷案件详细信息
     */
    @GetMapping("/getCockCaseInfo")
    public R<CockCaseVo> getCockCaseInfo(@RequestParam @NotNull Integer ficaseid){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cockcollectService.getCockCaseInfo(user,ficaseid));
    }
}
